cmake_minimum_required(VERSION 3.0)

option(LUA_DIR "Path of Lua 5.4 source dir" OFF)
option(LUAJIT_DIR "Path of LuaJIT 2.1 source dir" OFF)

if(LUAJIT_DIR)
  project(luajit)
  include(LuaJIT.cmake)
  if (PARENT_DIRECTORY)
    set(LUA_TARGET luajit PARENT_SCOPE)
    set(LUA_LIBRARIES libluajit PARENT_SCOPE)
  endif()
elseif(LUA_DIR)
  project(lua)
  include(lua.cmake)
  if (PARENT_DIRECTORY)
    set(LUA_TARGET lua PARENT_SCOPE)
    set(LUA_LIBRARIES liblua PARENT_SCOPE)
  endif()
else()
  message(FATAL_ERROR "Must set LUAJIT_DIR or LUA_DIR to build with CMake")
endif()
